import { request } from '@utils/http'
import {
  IhospitalListParams,
  IhospitalListRes,
  IdictList,
  Status,
  IhosDetailRes,
  IdepList,
  IscheduleRuleRes,
  IscheduleDetailList,
} from './model/hospitalListTypes'
// 获取医院列表表格数据的函数
export function reqGetHospitalList({
  page,
  limit,
  hosname,
  hoscode,
  hostype,
  provinceCode,
  cityCode,
  districtCode,
  status,
}: IhospitalListParams) {
  return request.get<any, IhospitalListRes>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: {
        page,
        limit,
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  )
}

// 获取省数据的函数
export const reqGetProvince = (dictCode = 'province') =>
  request.get<any, IdictList>(`/admin/cmn/dict/findByDictCode/${dictCode}`)

// 获取市,或区,或医院类型数据的函数
export const reqGetCoDoT = (parentId = '10000') =>
  request.get<any, IdictList>(`/admin/cmn/dict/findByParentId/${parentId}`)
// 修改医院状态
export const reqUpdateHosStatus = (id: number, status: Status) =>
  request.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
// 获取医院详情
export const reqGetHosDetail = (id: number) =>
  request.get<any, IhosDetailRes>(`/admin/hosp/hospital/show/${id}`)

// 获取科室数据
export const reqGetDepList = (hoscode: string) =>
  request.get<any, IdepList>(`/admin/hosp/department/${hoscode}`)
// 获取排班规则
export const reqGetScheduleRules = (
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) =>
  request.get<any, IscheduleRuleRes>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  )
// 获取排班规则详情
export const reqGetScheduleRulesDetail = (
  hoscode: string,
  depcode: string,
  workDate: string
) =>
  request.get<any, IscheduleDetailList>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  )
